import request from '@/utils/request'

export function getOrdersByDeliveryProcess(params) {
  return request({
    url: '/order/page',
    method: 'get',
    params
  })
}

export function getOrderDetail(orderId) {
  return request({
    url: `/order/detail/${orderId}`,
    method: 'get'
  })
}

/**
 * 配送员抢单
 * @param {object} data - 包含orderId, deliveryId, deliveryPhone
 */
export function grabOrder(data) {
  return request({
    url: '/order/grab',
    method: 'post',
    data
  })
}

/**
 * 配送员确认取货
 * @param {object} data - 包含orderId
 */
export function confirmPickup(data) {
  return request({
    url: '/order/confirmPickup',
    method: 'post',
    data
  })
}

/**
 * 配送员确认送达
 * @param {object} data - 包含orderId
 */
export function completeOrder(data) {
  return request({
    url: '/order/complete',
    method: 'post',
    data
  })
}

/**
 * 获取已完成的订单列表
 * @param {object} params - 包含deliveryUserId, pageNo, pageSize
 */
export function getCompletedOrders(params) {
  return request({
    url: '/order/completed',
    method: 'get',
    params
  })
}

/**
 * 获取公告列表
 */
export function getNoticeList() {
  return request({
    url: '/notice/list',
    method: 'get'
  })
}

/**
 * 获取公告详情
 * @param {string} id - 公告ID
 */
export function getNoticeDetail(id) {
  return request({
    url: `/notice/detail/${id}`,
    method: 'get'
  })
}